//
//  PlayView.m
//  RadioUrl
//
//  Created by ios on 16/4/22.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "PlayView.h"
#import <UIImageView+WebCache.h>
// 定义之后可以不用带mas_前缀
#define MAS_SHORTHAND
// 定义之后equalTo等于mas_equalTo
#define MAS_SHORTHAND_GLOBALS

#define width5 [UIScreen mainScreen].bounds.size.width/5
//#import <Masonry.h>


@implementation PlayView
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        self.preButton.tintColor = [UIColor orangeColor];
        self.playButton.tintColor = [UIColor orangeColor];
        self.nextButton.tintColor = [UIColor orangeColor];
    }
    return self;
}
-(void)playViewWithImageName:(NSString *)imageName radioName:(NSString *)radioName endTime:(NSString *)timeLength{
    
    self.endTime.text =timeLength;
    self.radioTitle.text = radioName;
    NSLog(@"%@",imageName);
    [self.radioImage sd_setImageWithURL:[NSURL URLWithString:imageName]];
    
    
//    self.radioTitle.numberOfLines = 0;
    self.scrollView.contentSize = CGSizeMake(200, 60);
    if (self.timer.valid) {
        [self.timer invalidate];
//        self.timer = nil;
    }
    self.timer = [NSTimer  scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(rock) userInfo:nil repeats:YES];
}

-(void)rock{
    static CGFloat x = 0;
    if (self.scrollView.contentOffset.x == 150) {
      
        self.scrollView.contentOffset = CGPointMake(0, 0);
        x = 0;
    }else{
        x = x +2;
        self.scrollView.contentOffset = CGPointMake(x, 0);
    }
}
- (IBAction)sliderSeekToTime:(id)sender {
    [self.delegate sliderSeekToTime];
}

- (IBAction)backBtnPress:(id)sender {
    [self.delegate backBtnPressed];
}
- (IBAction)preBtnPress:(id)sender {
    [self.delegate preBtnPressed];
}


- (IBAction)nextBtnPress:(id)sender {
    [self.delegate nextBtnPressed];
    
}
- (IBAction)playBtnPress:(id)sender {
    
    [self.delegate playBtnPressed];
}


@end
